package team.knowers.firm.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import team.knowers.firm.common.convention.result.Result;
import team.knowers.firm.common.convention.result.Results;
import team.knowers.firm.dao.entity.NoticeDO;
import team.knowers.firm.dto.req.AddNoticeReqDTO;
import team.knowers.firm.dto.req.PageNoticeInfoReqDTO;
import team.knowers.firm.service.NoticeService;

@RestController
@RequiredArgsConstructor
public class NoticeController {
    private final NoticeService noticeService;

    @PostMapping("/api/firm/addNotice")
    public Result<Boolean> addNotice(@RequestBody AddNoticeReqDTO notice) {
        return Results.success(noticeService.addNotice(notice));
    }
    @PostMapping("/api/firm/deleteNotice")
    public Result<Boolean> deleteNotice(int id){
        return Results.success(noticeService.deleteNotice(id));
    }
    @GetMapping("/api/firm/getAllNoticesPage")
    public Result<IPage<NoticeDO>> getAllNoticesPage(PageNoticeInfoReqDTO reqDTO){
        return Results.success(noticeService.getAllNoticesPage(reqDTO));
    }
}
